package com.qujia.station.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.github.pagehelper.PageInfo;
import com.qujia.common.core.controller.BaseController;
import com.qujia.common.core.domain.AjaxResult;
import com.qujia.station.domain.dto.OutboundRecordsDto;
import com.qujia.station.domain.dto.OutboundRecordsQueryDto;
import com.qujia.station.domain.vo.OutboundRecordsVo;
import com.qujia.station.service.OutboundRecordsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "商品调拨出库接口")
@RestController
@RequestMapping("/outboundRecords")
public class OutboundRecordsController extends BaseController {

    @Autowired
    private OutboundRecordsService outboundRecordsService;

    @PostMapping("/addOutboundOrder/add")
    @ApiOperation(value = "新增调拨出库商品信息", httpMethod = "POST")
    public AjaxResult addOutboundOrder(@Valid @RequestBody OutboundRecordsDto outboundRecordsDto){
        return AjaxResult.success(outboundRecordsService.addOutboundOrder(outboundRecordsDto));
    }

    @GetMapping("/selectOutboundOrderDetail/{outboundRecordsId}")
    @ApiOperation(value = "查询商品调拨出库详情", httpMethod = "GET")
    public AjaxResult selectOutboundOrderDetail(@PathVariable Long outboundRecordsId){
        return AjaxResult.success(outboundRecordsService.selectOutboundOrderDetail(outboundRecordsId));
    }

    @PostMapping("/selectOutboundList/list")
    @ApiOperation(value = "查询商品出库列表", httpMethod = "POST")
    public R<PageInfo> selectOutboundList(@RequestBody OutboundRecordsQueryDto outboundRecordsQueryDto){
        PageInfo<OutboundRecordsVo> pageInfo = outboundRecordsService.selectOutboundList(outboundRecordsQueryDto);
        return R.ok(pageInfo);
    }
}
